﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.IO;

using EnvironmentalMonitor.Support.Resource;

namespace EnvironmentalMonitor.WebApplication.Manage.Log
{
    /// <summary>
    /// 列表页面类
    /// </summary>
    public partial class List : EnvironmentalMonitor.WebApplication.Abstract.AbstractSecurityPage
    {
        private List<string> _Urls;
        /// <summary>
        /// Url集合
        /// </summary>
        public List<string> Urls
        {
            get
            {
                return this._Urls;
            }
            set
            {
                this._Urls = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.Urls = new List<string>();
            if (!string.IsNullOrEmpty(Variable.LogDirectory))
            {
                if (Variable.LogDirectory.IndexOf(HttpRuntime.AppDomainAppPath) == 0)
                {
                    DirectoryInfo directoryInfo = new DirectoryInfo(Variable.LogDirectory);
                    FileInfo[] fileInfos = directoryInfo.GetFiles("*.*", SearchOption.AllDirectories);

                    if (fileInfos != null)
                    {
                        for (int i = 0; i < fileInfos.Length; i++)
                        {
                            string url = fileInfos[i].FullName.Replace(HttpRuntime.AppDomainAppPath, EnvironmentalMonitor.Support.Resource.Variable.VirtualRootPath).Replace("\\", "/");
                            this.Urls.Add(url);
                        }
                    }
                }
            }
        }
    }
}